home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
dev
/
c
/
EGCSWOSAlib.lha
/
src.lha
/
TimeDelay.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-04
|
2KB
|
54 lines
/*
** amiga.lib for vbcc-PowerOpen/WarpOS
**
** TimeDelay()
**
** V0.2 19-Apr-98 phx
** replaced <clib/powerpc/powerpc_protos.h> by <clib/powerpc_protos.h>
** V0.1 15-Mar-98 phx
** created
*/
#include <exec/memory.h>
#include <devices/timer.h>
#include <proto/exec.h>
#include <powerpc/powerpc_protos.h>
#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
(l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
LONG TimeDelay(long unit, unsigned long secs, unsigned long microsecs)
{
struct PortIO {
struct timerequest treq;
struct MsgPort port;
} *portio;
long ret=-1;
if ((portio = (struct PortIO *)AllocVecPPC(sizeof(struct PortIO),
MEMF_CLEAR|MEMF_PUBLIC,0)))
{
portio->port.mp_Node.ln_Type=NT_MSGPORT;
if ((BYTE)(portio->port.mp_SigBit=AllocSignal(-1))>=0)
{
portio->port.mp_SigTask=FindTask(NULL);
NEWLIST(&portio->port.mp_MsgList);
portio->treq.tr_node.io_Message.mn_Node.ln_Type=NT_MESSAGE;
portio->treq.tr_node.io_Message.mn_ReplyPort=&portio->port;
if (!(OpenDevice(TIMERNAME,unit,&portio->treq.tr_node,0)))
{
portio->treq.tr_node.io_Command=TR_ADDREQUEST;
portio->treq.tr_time.tv_secs=secs;
portio->treq.tr_time.tv_micro=microsecs;
if (!DoIO(&portio->treq.tr_node))
ret=0;
CloseDevice(&portio->treq.tr_node);
}
FreeSignal(portio->port.mp_SigBit);
}
FreeVecPPC(portio);
}
return ret;
}